package com.tnxst.phexamination.public_health_docking_interface;

import com.tnxst.phexamination.constant.Trade;
import com.tnxst.phexamination.dto.TCMHealthDTO;
import com.tnxst.phexamination.utils.ReflectUtils;
import com.tnxst.phexamination.utils.StringUtils;
import com.tnxst.phexamination.utils.WebServiceUtils;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;

public class TCMHealthElderlyInterface {

    /**
     * 71-1 老年人中医药管理查询列表
     * @param pageSize
     * @param pageIndex
     * @param regionCode
     * @param response
     */
    public static void queryTcmElderList(Integer pageSize, Integer pageIndex, String regionCode,
                                         WebServiceUtils.Response<List> response){
        String trade = Trade.TCM_ELDER.QUERY_TCM_ELDER_LIST;
        Map<String, Object> data = StringUtils.getPageDataMap(pageSize, pageIndex);
        data.put("RegionCode",regionCode);
        WebServiceUtils.call(trade,data,response);
    }

    /**c
     * 71-4 新增或更新中医药随访记录
     * @param tcmHealthDTO
     * @param response
     */
    public static void saveOrUpdateTcmElderFollow(TCMHealthDTO tcmHealthDTO, WebServiceUtils.Response response){
        String trade = Trade.TCM_ELDER.SAVE_OR_UPDATE_TCM_ELDER_FOLLOW;
        Map<String, Object> data = StringUtils.getDataMap();
        Map<String, Object> oldPeopleTcHealtItem = new LinkedHashMap<>();
        Map<String, Object> examChsConstitutionItem = new LinkedHashMap<>();
        data.put("OldPeopleTcHealtItem",oldPeopleTcHealtItem);
        data.put("ExamChsConstitutionItem",examChsConstitutionItem);
        fillTCMHealthElderlyFollow(tcmHealthDTO,oldPeopleTcHealtItem,examChsConstitutionItem);
        WebServiceUtils.call(trade,data,response);

    }

    /**
     * 71-5 获取老年人中医保健随访记录详情
     * @param id
     * @param response
     */
    public static void queryTcmElderFollowDetails(String id, WebServiceUtils.Response<Map> response){
        String trade = Trade.TCM_ELDER.QUERY_TCM_ELDER_FOLLOW_DETAILS;
        Map<String, Object> data = StringUtils.getDataMap();
        data.put("ID",id);
        WebServiceUtils.call(trade,data,response);
    }



    /**
     * 填充中医药随访记录
     * @param tcmHealthDTO
     * @param oldPeopleTcHealtItem
     * @param examChsConstitutionItem
     */
    private static void fillTCMHealthElderlyFollow(TCMHealthDTO tcmHealthDTO, Map<String, Object> oldPeopleTcHealtItem,
                                                   Map<String, Object> examChsConstitutionItem){
        String[] oldPeopleTcHealtItemNames = {"ID","Resident","TcHealthGuide","TcHealthHighScore","TcHealthGuides","FollowUpDate","NextFollowUpDate","DoctorName","DoctorID","TcHealthGuideOther",
                "A01","A02","A03","A04","A05","A06","A07","A08","A09","A10","A11","A12","A13","A14","A15","A16","A17","A18","A19",
                "A20","A21","A22","A23","A24","A25","A26","A27","A28","A29","A30","A31","A32","A33"};

        String[] examChsConstitutionItemNames = {"ID","ModerateQuality","QualityDeficiency","YangQuality","YinQuality","Phlegm","DampHeat","BloodQuality","QiQuality","TeBingQuality"};

        ReflectUtils.objectToMap(oldPeopleTcHealtItemNames,tcmHealthDTO,oldPeopleTcHealtItem);

        ReflectUtils.objectToMap(examChsConstitutionItemNames,tcmHealthDTO,examChsConstitutionItem);

    }





}
